home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / fndwnd / findwnd.frm < prev    next >
Text File  |  1995-05-08  |  4KB  |  132 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Find Window"
  5.    ClientHeight    =   1365
  6.    ClientLeft      =   1125
  7.    ClientTop       =   2250
  8.    ClientWidth     =   4335
  9.    Height          =   1770
  10.    Icon            =   FINDWND.FRX:0000
  11.    Left            =   1065
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   1365
  16.    ScaleWidth      =   4335
  17.    Top             =   1905
  18.    Width           =   4455
  19.    Begin TextBox Text2 
  20.       Height          =   315
  21.       Left            =   1320
  22.       TabIndex        =   1
  23.       Text            =   "Microsoft Excel"
  24.       Top             =   960
  25.       Width           =   2055
  26.    End
  27.    Begin CommandButton btnQuit 
  28.       Caption         =   "&Quit"
  29.       Height          =   615
  30.       Left            =   3540
  31.       TabIndex        =   3
  32.       Top             =   660
  33.       Width           =   735
  34.    End
  35.    Begin TextBox Text1 
  36.       Height          =   315
  37.       Left            =   1320
  38.       TabIndex        =   0
  39.       Text            =   "XLMAIN"
  40.       Top             =   660
  41.       Width           =   2055
  42.    End
  43.    Begin CommandButton btnFind 
  44.       Caption         =   "&Find"
  45.       Height          =   615
  46.       Left            =   3540
  47.       TabIndex        =   2
  48.       Top             =   60
  49.       Width           =   735
  50.    End
  51.    Begin PictureBox Picture1 
  52.       BorderStyle     =   0  'None
  53.       Height          =   615
  54.       Left            =   1500
  55.       ScaleHeight     =   615
  56.       ScaleWidth      =   1815
  57.       TabIndex        =   4
  58.       TabStop         =   0   'False
  59.       Top             =   0
  60.       Width           =   1815
  61.    End
  62. End
  63. '**********************************************************'
  64. '*                                                        *'
  65. '*                      Find Window                       *'
  66. '*                                                        *'
  67. '*   Find Window allows you to type a Caption and/or      *'
  68. '*   ClassName into the textboxes on the form and see     *'
  69. '*   if a Window exists that matches those criteria.  I   *'
  70. '*   use it to check on the format of captions used in    *'
  71. '*   applications to make sure I haven't mistaken a set   *'
  72. '*   of parenthesis for a set of square brackets, etc...  *'
  73. '*   It's also useful when you use SPY to find Class      *'
  74. '*   Names and you want to make sure it's not lying to    *'
  75. '*   you<g>.  Do with it as you will.                                            *'
  76. '*                                                        *'
  77. '*   Let me know if you find it useful, or not.           *'
  78. '*                                                        *'
  79. '*   Gregg Irwin CIS:ID  72450,676                        *'
  80. '*                                                        *'
  81. '**********************************************************'
  82.  
  83. DefInt A-Z
  84.  
  85. Declare Function FindWindow% Lib "user" (ByVal lpClassName As Any, ByVal lpCaption As Any)
  86.  
  87. Const KEY_ENTER = 13
  88. Const NULL = 0&
  89.  
  90. Sub btnFind_Click ()
  91.     lpClassName$ = Text1.Text
  92.     lpCaption$ = Text2.Text
  93.     Picture1.Cls
  94.     Picture1.Print " Handle = "; FindWindow(lpClassName$, NULL)
  95.     Picture1.Print " Handle = "; FindWindow(NULL, lpCaption$)
  96.     Picture1.Print " Handle = "; FindWindow(lpClassName$, lpCaption$)
  97. End Sub
  98.  
  99. Sub btnQuit_Click ()
  100.     End
  101. End Sub
  102.  
  103. Sub Form_Paint ()
  104.      CurrentX = 120: CurrentY = 720
  105.     Print "ClassName :"
  106.      CurrentX = 420: CurrentY = 1020
  107.     Print "Caption :"
  108.      CurrentX = 0: CurrentY = 0
  109.     Print " ClassName Only"
  110.     Print " Caption Only"
  111.     Print " Class & Caption"
  112. End Sub
  113.  
  114. Sub Form_Unload (Cancel As Integer)
  115.     End
  116. End Sub
  117.  
  118. Sub Text1_KeyPress (KeyAscii As Integer)
  119.     If KeyAscii = KEY_ENTER Then    'If Enter is hit
  120.         KeyAscii = 0                'Supress beep
  121.         SendKeys "{TAB}"            'Go to next field
  122.     End If
  123. End Sub
  124.  
  125. Sub Text2_KeyPress (KeyAscii As Integer)
  126.     If KeyAscii = KEY_ENTER Then
  127.         KeyAscii = 0
  128.         SendKeys "{TAB}"
  129.     End If
  130. End Sub
  131.  
  132.